package com.lottery.ruok.lottrey.activity;

import android.os.Bundle;
import android.widget.ListView;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.adapter.AddUserAdapter;
import com.lottery.ruok.lottrey.retrofitModule.RetrofitBase;
import com.lottery.ruok.lottrey.retrofitModule.RxHelper;
import com.lottery.ruok.lottrey.retrofitModule.RxSubscribe;
import com.lottery.ruok.lottrey.retrofitModule.request.GetBlockListRequest;
import com.lottery.ruok.lottrey.retrofitModule.response.GetBlockListResponse;
import com.lottery.ruok.lottrey.userInfo.UserInfo;

import butterknife.BindView;
import butterknife.ButterKnife;
/*
* 添加新成员
* */
public class AddNewUserActivity extends BaseActivity {
    private GetBlockListResponse getBlockListResponse;
    private AddUserAdapter addUserAdapter;

    @BindView(R.id.listview)
    ListView listview;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_user);
        ButterKnife.bind(this);

        init();
    }

    private void init() {
        RetrofitBase.getRetrofit().create(GetBlockListRequest.class)
                .getResult(UserInfo.getToken(), UserInfo.getRoomId() )
                .compose(RxHelper.<GetBlockListResponse>handleResult())
                .subscribe(new RxSubscribe<GetBlockListResponse>(this) {
                    @Override
                    protected void _onNext(GetBlockListResponse getBlockListResponses) {
                        getBlockListResponse = getBlockListResponses;

                        addUserAdapter = new AddUserAdapter(getBlockListResponse, AddNewUserActivity.this);
                        listview.setAdapter(addUserAdapter);
                    }

                    @Override
                    protected boolean showDialog() {
                        return true;
                    }
                });
    }
}
